package com.linkai.baidu;

import java.util.Scanner;

/**
 * @Description: HTTP 状态码
 * @Author: 林凯
 * @Date: 2021/10/18 18:58
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = Integer.valueOf(sc.nextLine());
        String[] array = new String[T];
        for (int i = 0; i < T; i++) {
            array[i] = sc.nextLine();
        }

        for (int i = 0; i < T; i++) {
            char[] chars = array[i].toCharArray();
            if (chars[0] == '4' || chars[0] == '5') {
                System.out.println("YES");
                continue;
            }
            System.out.println("NO");
        }


    }
}
